import request from '@/utils/request'

import {
	ref
} from 'vue'
export default () => {
	const categories = ref([])
	const childrenCates = ref([])
	const childProducts = ref([])
	const getCategory = async (id = 1) => {
		categories.value = await request.get(`mini/category/top`)
	}

	const getCategoryChildren = async (id = 1, locObj) => {
		const {cates,products} = await request.get(`mini/category/${id}/children`)
		childrenCates.value = cates
		childProducts.value = products
	}

	return {
		getCategoryChildren,
		getCategory,
		categories,
		childrenCates,
		childProducts
	}
}